package com.learn.springboot.mapper;

import com.learn.springboot.bean.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

/**
 * @author dyz
 * @program learning
 * @create 2019-09-20 14:47
 */
@Mapper
public interface UserMapper {

    @Insert("INSERT INTO user (name, age) VALUES(#{name}, #{age})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(User user);

    @Select("SELECT id, name, age FROM user WHERE name = #{name}")
    User findByName(String name);
}
